 package com.yllt4cloud.push.server;


 import com.yllt4cloud.push.coder.MyDecoder;
 import com.yllt4cloud.push.coder.MyEncoder;
 import org.jboss.netty.channel.ChannelPipeline;
 import org.jboss.netty.channel.ChannelPipelineFactory;
 import org.jboss.netty.channel.Channels;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;


 @Component
  public class ServerPipelineFactory implements ChannelPipelineFactory {
     @Autowired
     public ServerHandler serverHandler;

     public ChannelPipeline getPipeline() throws Exception {
         ChannelPipeline pipeLine = Channels.pipeline();
         //服务器下发到客户端(下行)需要实现 ChannelDownstreamHandler     接受客户端消息(上行)需要实现 ChannelUpstreamHandler
         //处理流程 上行：decoder-->handler   下行：handle-->encoder
 //		pipeLine.addLast("decoder", new Decoder(Integer.MAX_VALUE, 0, 4));
 //		pipeLine.addLast("encoder", new Encoder(4));

         pipeLine.addLast("decoder", new MyDecoder());
         pipeLine.addLast("encoder", new MyEncoder());
         pipeLine.addLast("handler", serverHandler);
         return pipeLine;
     }


 }
